home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * Handler.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- if (!IS_isModuleInitialized("IS.NOF.UTIL.LOGGING.Handler"))
- {
- /****h* NOF_JavaScript_Library/NOF.UTIL.LOGGING.Handler
- *
- * NAME
- * NOF.UTIL.LOGGING.Handler
- *
- * DESCRIPTION
- *
- * Base class for Logger's <code>Handler</code> objects.
- * A Handler has a minimum level for records to be processed,
- * has a Formatter to format the message and
- * a filter which can be use to enable or disable the processing
- * of the log records sent to this Handler.
- * Default formatter is a LOGGING.Formatter object and
- * default filter is a LOGGING.Filter. The Handler is initialized to
- * process all the messages (level set to LOGGING.Level.FINEST).
- * This Handler will finally call the javascript alert() after
- * processing the log record.
- *
- * @see <code>ConsoleHandler</code>
- *
- * External dependencies:
- ****/
-
- /**
- * constructor
- * @param logger instance of the Logger who "owns" this Handler
- **/
- function LOGGING_Handler( logger ) {
- this.__proto__ = LOGGING_Handler.prototype;
-
- this.logger = logger;
-
- this.level = LOGGING.Level.FINEST;
- this.filter = new LOGGING.Filter();
- this.formatter = new LOGGING.Formatter();
- }
- {
- var member = LOGGING_Handler.prototype;
- member.CLASS_NAME = "LOGGING.Handler";
-
- var method = LOGGING_Handler.prototype;
-
- /**
- * Output the processed string (this implementation is just firing an alert).
- * Subclasses can only overwrite this method to notify other media
- * with the processed message
- *
- * @param str message string
- **/
- method.output = function (/*string*/ str) {
- var nofAlertEnabled = IS_isModuleInitialized("IS.NOF.DIALOGS.Messages");
- if (!nofAlertEnabled) {
- NOF.loadClasses(NOF.App.getSystemDirectory() + "FSI/",
- "lib/nof/dialogs/Messages");
- nofAlertEnabled = IS_isModuleInitialized("IS.NOF.DIALOGS.Messages");
- }
- if (nofAlertEnabled) {
- NOF.DIALOGS.Messages.alert(str, this.logger.getLoggerName(), "OK", null, 300, 400);
- } else {
- alert(str);
- }
- }
-
- /**
- * Determine if a record will be processed by this Handler.
- *
- * @param logRecord
- * @return true if the level of logRecord is less or equal than this Handler's level.
- **/
- method.isLoggable = function (/*NOF.UTIL.LOGGING.LogRecord*/ logRecord) {
- return ( (this.level >= logRecord.getLevel()) && this.filter.isLoggable(logRecord) );
- }
-
- /**
- * publish the log record. If the log record is loggable, output the formated string
- * returned by the associated formatter.
- * @param logRecord
- **/
- method.publish = function (/*NOF.UTIL.LOGGING.LogRecord*/ logRecord) {
- if (this.isLoggable(logRecord)) {
- var ft = this.formatter.format(logRecord);
- this.output(ft);
- }
- }
-
- /**
- * Set a new Formatter
- *
- * @param nFormatter
- **/
- method.setFormatter = function (/*NOF.UTIL.LOGGING.Formatter*/ nFormatter) { this.formatter = nFormatter; }
-
- /**
- * Get the Formatter associated to this Handler
- *
- * @return the Formatter of the Handler
- **/
- method.getFormatter = function () { return this.formatter; }
-
- /**
- * Set a new Filter
- *
- * @param nFilter
- **/
- method.setFilter = function (/*NOF.UTIL.LOGGING.Filter*/ nFilter) { this.filter = nFilter; }
-
- /**
- * Get the Filter associated to this Handler
- *
- * @return the Filter of the Handler
- **/
- method.getFilter = function () { return this.filter; }
-
- /**
- * Set the minumum level from which the records passed to this Handler should be processed
- * @param level one of the values defined by LOGGING.Level interface
- **/
- method.setLevel = function (/*NOF.UTIL.LOGGING.Level*/ level) { this.level = level; }
-
- /**
- * Get the minimum log level from which the records passed to this Handler will be processed.
- * @return level
- **/
- method.getLevel = function () { return this.level; }
- }
-
- LOGGING.__proto__.Handler = LOGGING_Handler;
- }